package de.hdodenhof.circleimageview.sample.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.daimajia.numberprogressbar.NumberProgressBar;
import com.robinhood.ticker.TickerView;

import net.frakbot.jumpingbeans.JumpingBeans;

import androidx.fragment.app.Fragment;
import de.hdodenhof.circleimageview.sample.R;
import de.hdodenhof.circleimageview.sample.ui.fragment.text.ExpandableActivity;
import de.hdodenhof.circleimageview.sample.ui.fragment.text.TickerActvity;
import me.zhanghai.android.materialprogressbar.IndeterminateHorizontalProgressDrawable;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;

public class TextFragment extends Fragment {
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_text, null);
        view.findViewById(R.id.btn_ticker).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), TickerActvity.class));
            }
        });

        view.findViewById(R.id.btn_expandable).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), ExpandableActivity.class));
            }
        });

        TextView txtExpandable = (TextView)view.findViewById(R.id.btn_expandable);
        JumpingBeans jumpingBeans1 = JumpingBeans.with(txtExpandable)
                .appendJumpingDots()
                .build();

        final TextView txtTicker = (TextView) view.findViewById(R.id.btn_ticker);
        JumpingBeans jumpingBeans2 = JumpingBeans.with(txtTicker)
                .makeTextJump(0, 5)
                .setIsWave(false)
                .setLoopDuration(1000)  // ms
                .build();

        TextView mOutput = (TextView)view.findViewById(R.id.output);
        TextView mAutofitOutput = (TextView)view.findViewById(R.id.output_autofit);

        ((EditText)view.findViewById(R.id.input)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                // do nothing
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                mOutput.setText(charSequence);
                mAutofitOutput.setText(charSequence);
            }

            @Override
            public void afterTextChanged(Editable editable) {
                // do nothing
            }
        });

        return view;
    }
}
